﻿<Window x:Class="HouseKeepingPL.UserControls.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:UserControls="clr-namespace:HouseKeepingPL.UserControls"
        Title="House Keeping"
        Width="800"
        Height="500"
        DataContext="{Binding Main,
                              Source={StaticResource Locator}}"
        Icon="/Resources/money.png"
        ResizeMode="CanResizeWithGrip"
        WindowStartupLocation="CenterScreen"
        WindowStyle="SingleBorderWindow">



    <Window.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
            <GradientStop Offset="1" Color="#FF3164a5" />
            <GradientStop Offset="0" Color="#FF8AAED4" />
        </LinearGradientBrush>
    </Window.Background>

    <Window.Resources>
        <ControlTemplate x:Key="validationTemplate">
            <DockPanel>
                <Border BorderBrush="Red" BorderThickness="1">
                    <AdornedElementPlaceholder />
                </Border>
                <Border Width="20"
                        Height="20"
                        Margin="5,0,0,0"
                        Background="Red"
                        CornerRadius="10"
                        DockPanel.Dock="right"
                        ToolTip="{Binding ElementName=customAdorner,
                                          Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
                    <TextBlock HorizontalAlignment="center"
                               VerticalAlignment="center"
                               FontSize="20"
                               FontWeight="Bold"
                               Foreground="WhiteSmoke">
                        !!
                    </TextBlock>
                </Border>
            </DockPanel>
        </ControlTemplate>
        <Style x:Key="MyTabStyle" TargetType="Grid">
            <Setter Property="Background" Value="AliceBlue" />
        </Style>

        <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="PasswordBoxInError" TargetType="{x:Type PasswordBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="ComboBoxInError" TargetType="{x:Type ComboBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>

    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="*" />
            <RowDefinition Height="25" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <!--
                <MenuItem Header="_Account">
                <MenuItem Header="Log_in" />
                <MenuItem Header="Log_out" />
                </MenuItem>
            -->

            <MenuItem Command="{Binding LogoutCommand}" Header="Log_out" />
            <MenuItem Command="{Binding AboutCommand}" Header="A_bout" />
            <MenuItem Command="{Binding ApplicationExitCommand}" Header="E_xit" />

        </Menu>
        <TabControl Grid.Row="1" SelectedIndex="{Binding TabIndexProperty}">
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Height="18" Source="/Resources/key.ico" />
                        <TextBlock Margin="5,0,0,0" Text="Account" />

                    </StackPanel>
                </TabItem.Header>

                <Grid>
                    <AdornerDecorator>
                        <UserControls:AccountControl />
                    </AdornerDecorator>
                </Grid>

            </TabItem>
            <TabItem IsEnabled="{Binding Path=IsLoggedIn}">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Height="18" Source="/Resources/greenDownArrow.png" />
                        <TextBlock Margin="5,0,0,0" Text="Income" />
                    </StackPanel>
                </TabItem.Header>

                <Grid>
                    <AdornerDecorator>
                        <UserControls:Incomes />
                    </AdornerDecorator>
                </Grid>

            </TabItem>
            <TabItem IsEnabled="{Binding Path=IsLoggedIn}">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Height="18" Source="/Resources/redUpArrow.png" />
                        <TextBlock Margin="5,0,0,0" Text="Outcome" />
                    </StackPanel>
                </TabItem.Header>
                <Grid>
                    <AdornerDecorator>
                        <UserControls:Outcomes />
                    </AdornerDecorator>
                </Grid>
            </TabItem>
            <TabItem IsEnabled="{Binding Path=IsLoggedIn}">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Height="18" Source="/Resources/report.png" />
                        <TextBlock Margin="5,0,0,0" Text="Report" />
                    </StackPanel>
                </TabItem.Header>
                <Grid>
                    <UserControls:Reports />
                </Grid>
            </TabItem>
        </TabControl>
        <StatusBar Grid.Row="2"
                   Height="25"
                   HorizontalAlignment="Stretch"
                   VerticalAlignment="Top">
            <TextBlock Width="200" Text="{Binding Path=StatusBarConnectedAs}" />
            <Separator />
            <TextBlock Width="200" Text="{Binding Path=StatusBarLogonTime}" />
        </StatusBar>
    </Grid>


</Window>


